stage.set_axis(100)
stage.create_grid_overlay(10, "grey")
stage.set_background("soccerfield")
ballx = -80
bally = random.randint(-100,100)
# sprite = codesters.Sprite("image", x, y)
ball = codesters.Sprite("soccerball", ballx, bally)
netx = 90
nety = random.randint(-100,100)
# sprite = codesters.Sprite("image", x, y)
net = codesters.Sprite("soccernet", netx, nety)
net.flip_right_left()
#sprite = codesters.Line(x-start, y-start, x-end, y-end, "color")
line = codesters.Line(ballx, bally, netx, nety, "blue")
t = codesters.Teacher()
asks = t.find_function("ask")
try:
tval1 = asks[0][1]
except:
tval1 = "DNE"
try:
tval2 = slopeguess
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success("float" in tval1 and "slope" in tval1, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Ask for Float command to your code?")
t1.add_failure("float" in tval1 and "slope" not in tval1, "Did you change the string to ask for slope?")
t1.add_failure("int" in tval1, "Did you use an Ask for Integer command instead?")
t1.add_failure("float" not in tval1, "Did you Ask for a Float?")
t2 = TestObjective()
t2.add_success(tval2 == '"slopeguess"', "Great job!")
t2.add_failure(tval2 == "DNE", "Did you change the variable to slopeguess?")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)